import Vue from 'vue'
import Vue2OrgTree from 'vue2-org-tree'
// import 'vue2-org-tree/src/styles/org-tree.less'
Vue.use(Vue2OrgTree)
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElTreeSelect from 'el-tree-select'
Vue.use(ElTreeSelect)

// import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'
import '@/styles/index.scss' // global css
Vue.use(ElementUI, { size: 'small' })

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use(Viewer)
Vue.use(VXETable)

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon

import '@/permission' // permission control

// 菜单权限判断
import permission from '@/directive/permission/index.js' // 权限判断指令
Vue.directive('permission', permission)

import '@/utils/jsmpeg.min.js' // 摄像头

// import 'video.js/dist/video-js.css'
// import hls from 'videojs-contrib-hls'
// Vue.use(hls)

import MainPage from '@/components/main-page/index.vue'
Vue.component('MainPage', MainPage)
// import FormTable from '@/components/form-table/index.vue'
// Vue.component('FormTable', FormTable)

// import $ from 'jquery'

// Vue.prototype.$ = $
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// 更改package.json的版本号，自动清除用户浏览器缓存数据
const VUE_APP_VERSION = require('../package.json').version
const vers = window.localStorage.getItem('dpagmVueVersion')
if (VUE_APP_VERSION !== vers) {
  localStorage.clear()
  window.localStorage.setItem('dpagmVueVersion', VUE_APP_VERSION)
  location.reload()
}

// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }
import defaultSettings from '@/settings'
import { QWebChannel } from '@/utils/qwebchannel'
if (defaultSettings.isCEF) {
  // 创建QWebChannel对象
  new QWebChannel(window.qt.webChannelTransport, function (channel) {
    // 从QWebChannel对象中获取在Web页面中定义的对象
    Vue.prototype.QWebChannelSendObject = channel.objects.sendObject
  })
}

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: (h) => h(App)
})
